<?php
/**
 * @author Sergey Dostovalov
 */
class MarcField {
    protected $tag;
    public function  __construct($tag, array $subfields = array(), $ind1 = null, $ind2 = null)
    {
        $this->setTag($tag);
    }
    public function __destruct()
    {
        $this->tag = null;
    }
    public function getTag()
    {
        return $this->tag;
    }
    /**
     * @param string $tag field tag e.g. 245
     * @exception Exception
     */
    public function setTag($tag)
    {   $tag = trim($tag);
        if (strlen($tag) === 3 and (int)$tag > 0){
            $this->tag = $tag;
        }
        else throw new Exception('Wrong tag'); 
    }
    /**
     *
     * @return bool
     */
    public function isControlField()
    {
        if ($this instanceof MarcControlField) return true;
        return false;
    }
    /**
     *
     * @return bool
     */
    public function isDataField()
    {
        if ($this instanceof MarcDataField) return true;
        return false;
    }
     /**
     * Check for the field has a subfield with $code
     * @param string $code
     * @return bool
     */
    public function isHasSubfield($code){
        return false;
    }
    //stub for extended
    public function toRaw($toEncoding = null)
    {
        return false;
    }
    public function  __toString()
    {
        return $this->tag;
    }

}
?>
